﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Navigation;

namespace Lab1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        
        public MainWindow()
        {
            InitializeComponent();
        }
        private void BeginTest(object sender, RoutedEventArgs e)
        {
            UserAnswerService.Begin();
            QuestionService qService = new QuestionService();
            Question question;
            try
            {
                question = qService.getRoot();
            }
            catch {
                MessageBox.Show("Нет корневого вопроса в бд!");
                return;
            }
               Application.Current.Properties["questionId"] = question.Id;
            if (question.Type.Equals("Free"))
            {

                MainFrame.NavigationService.Navigate(new QuestionFree());
            }
            else
            {
                MainFrame.NavigationService.Navigate(new QuestionVariant());
            }
        }

        private void EditDataBase(object sender, RoutedEventArgs e)
        {
            MainFrame.NavigationService.Navigate(new Admin());
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown();
        }

        private void About(object sender, RoutedEventArgs e)
        {
            MainFrame.NavigationService.Navigate(new About());
        }
    }
}
